﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace S.EarTag.Domain.DataAccess
{
    public class Repository<T> where T : class, new()
    {
        private static readonly SqlSugarClient Db;
        static Repository()
        {
            Db = MyDbContext.CreateDbOmstance();
        }
        public static ISugarQueryable<T> Queryable => Db.Queryable<T>();
        public static bool Insert(T entity)
        {
            return Db.Insertable(entity).ExecuteCommand() > 0;
        }

        public static bool update(T entity)
        {
            return Db.Updateable(entity).ExecuteCommand() > 0;
        }
        public static bool Delete(T entity)
        {
            return Db.Deleteable(entity).ExecuteCommand() > 0;
        }

    }
}
